# -*- coding: utf-8 -*-
# @Time        :2025/3/3 10:41
# @Author      :文刀水寿
# @File        : 12_爬虫_urllib_异常.py
"""
 @Description :
"""
import urllib.request
import urllib.error

url = 'https://blog.csdn.net/sixpp/article/details/1457331311'

headers = {
    'user-agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Mobile Safari/537.36 Edg/133.0.0.0'
}
try:
    request = urllib.request.Request(url=url, headers=headers)

    response = urllib.request.urlopen(request)

    content = response.read().decode('utf8')

    print(content)
except urllib.error.HTTPError:
    print("系统正在升级。。。。")
